Heart diseases are among the most common causes of death in the world. Myocardial infarction (MI) requires fast detection with electrocardiogram (ECG) readings. In this paper, we present an end-to-end deep learning system for automated MI and ischemic abnormality detection based on ECG readings with explainability and web deployment. Three models of convolutional neural networks (CNNs) have been trained with one-dimensional inputs from the PTB-XL dataset (21,799 entries, 500 Hz, 10 seconds): 12-Lead CNN with multi-lead digital ECG input, Lead II CNN with single-lead ECG input, and Image CNN with scanned ECG images. 12-Lead CNN outperformed other models with ROC-AUC = 0.8991, sensitivity = 0.8674, specificity = 0.7580, and F1 score = 0.8436. Explainability with Grad-CAM [16] and saliency maps has been incorporated that conforms with the standard ECG pattern interpretation. All of our models have been integrated in an easily accessible web application with Streamlit Cloud to allow WFDB file, CSV, and image input with automatic route selection and report generation.
Introduction
This research focuses on developing an AI-based myocardial infarction (MI) detection system using ECG signals, deep learning, and explainable AI, with deployment as a web application.
The study addresses the challenge that ECG interpretation requires expert cardiologists, which are often unavailable in rural or underserved areas. To solve this, the authors propose a system using three CNN models (Lead II, 12-lead, and image-based CNN) to classify MI from ECG data. Unlike most existing works, the system also includes explainability (Grad-CAM and saliency maps) and a web-based deployment platform.
The models are trained on the PTB-XL dataset, with ECG signals preprocessed using normalization, filtering, and resampling. Since ECG image datasets are limited, a synthetic ECG image generation pipeline is used for training the image-based model. Each CNN is designed to process fixed-length ECG signals (5000 samples) and is trained using PyTorch with optimized hyperparameters.
The system architecture integrates input handling, preprocessing, CNN inference, explainability visualization, and report generation within a single Streamlit application. It supports multiple input formats such as WFDB files, CSV signals, and ECG images. The output includes predictions along with clinical explanations using Grad-CAM heatmaps and saliency maps, highlighting medically relevant ECG regions like ST segments and T-waves.
Results show strong performance, with the 12-lead CNN achieving the highest AUC (~0.90), followed by Lead II and image-based models. The system demonstrates that deep learning can effectively detect MI while maintaining clinical interpretability and real-world usability.
Conclusion
In this paper, we proposed a fully functional web platform for myocardial infarction and ischemic abnormality detection from ECG data. Three distinct models, trained on the publicly available PTB-XL database, handle multi-lead, single-lead, and ECG image inputs in a uniform pipeline. The 12-Lead CNN obtained ROC-AUC 0.8991 and F1 0.8436, comparable with other published works that lack both explainability and web-deployability. Additionally, the Grad-CAM activations demonstrated agreement with the known ECG markers of MI. Finally, the proposed platform is publicly available as a single-tier Streamlit Cloud web app.
Future work needs to collect real-life ECG image datasets to bridge the domain gap in the Image CNN. Extending classification to arrhythmia and conduction disorders increases the applicability of the models, as deep neural networks proved themselves on a variety of physiological signals [21]. Transformer-based architectures with inbuilt attention mechanism provide more intuitive explanations compared to post-hoc Grad-CAM analysis. Evaluating on Indian ECGs will confirm generalization to local population demographics and ECG recording practices.
References
[1] Z. Chen et al., \"Acute myocardial infarction detection using deep learning with PTB-XL dataset,\" IEEE Access, 2021.
[2] Y. Zhao et al., \"Reliable detection of myocardial ischemia using machine learning from ECG and VCG signals,\"Comput. Biol. Med., 2022.
[3] X. Wu et al., \"Deep learning networks accurately detect ST-segment elevation and culprit vessel in myocardial infarction,\"JACC Clin. Electrophysiol., 2022.
[4] A. Hasbullah et al., \"Hybrid CNN-BiLSTM model for myocardial infarction detection on PTB-XL,\"Appl. Sci., 2023.
[5] D. Sheth et al., \"Time-frequency transform with a lightweight CNN-LSTM for myocardial infarction detection,\"Biomed. Signal Process. Control, 2024.
[6] A. Gragnaniello et al., \"Real-time myocardial infarction detection using edge-AI on ECG devices,\"IEEE Trans. Biomed. Eng., 2024.
[7] Y. Chen et al., \"Multi-domain feature fusion CNN for MI detection and localization,\" Expert Syst. Appl., 2025.
[8] M. Sraitih et al., \"Noise robustness of classical machine learning for myocardial infarction detection,\"Diagnostics, 2022.
[9] T. Yousuf et al., \"Inferior MI detection from Lead II using 2D-CNN with GAF/GADF encoding,\" Bioengineering, 2023.
[10] M. Gustafsson et al., \"Development and validation of a DL ECG prediction of MI in ED patients,\"Eur. Heart J. Digit. Health, 2023.
[11] P. Prabhakararao and S. Dandapat, \"Attentive RNN-based network to fuse 12-lead ECG and clinical features,\" IEEE J. Biomed. Health Inform., 2020.
[12] K. Pawelczyk et al., \"Interpretable ECG analysis for MI using counterfactual explanations,\"Artif. Intell. Med., 2024.
[13] R. Radwa et al., \"Deep learning-based approaches for myocardial infarction detection: A review,\"IEEE Access, 2024.
[14] P. Wagner et al., \"PTB-XL, a large publicly available electrocardiography dataset,\"Sci. Data, vol. 7, no. 1, p. 154, 2020.
[15] M. Hammad et al., \"Automated detection of MI and heart conduction disorders using deep learning,\"IEEE Access, 2022.
[16] R. R. Selvaraju et al., \"Grad-CAM: Visual explanations from deep networks via gradient-based localization,\"Proc. IEEE ICCV, pp. 618–626, 2017.
[17] S. Kshama et al., \"ECG-Image-Kit: A synthetic image generation toolkit for ECG digitization research,\" 2023.
[18] A. Y. Hannun et al., \"Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network,\"Nature Medicine, vol. 25, no. 1, pp. 65–69, 2019.
[19] S. Mousavi and F. Afghah, \"Inter- and intra-patient ECG heartbeat classification for arrhythmia detection: A sequence to sequence deep learning approach,\"Proc. IEEE Int. Conf. Acoustics, Speech and Signal Processing (ICASSP), 2019, pp. 1308–1312.
[20] U. R. Acharya et al., \"A deep convolutional neural network model to classify heartbeats,\"Computers in Biology and Medicine, vol. 89, pp. 389–396, 2017.
[21] O. Faust et al., \"Deep learning for healthcare applications based on physiological signals: A review,\"Computer Methods and Programs in Biomedicine, vol. 161, pp. 1–13, 2018.
[22] S. Kiranyaz et al., \"1D convolutional neural networks and applications: A survey,\" Mechanical Systems and Signal Processing, vol. 151, p. 107398, 2021.
[23] D. P. Kingma and J. Ba, \"Adam: A method for stochastic optimization,\" inProc. Int. Conf. Learning Representations (ICLR), 2015.
[24] B. Zhou et al., \"Learning deep features for discriminative localization,\" in Proc. IEEE Conf. Computer Vision and Pattern Recognition (CVPR), 2016, pp. 2921–2929.
[25] A. L. Goldberger et al., \"PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals,\"Circulation, vol. 101, no. 23, pp. e215–e220, 2000.
[26] G. B. Moody and R. G. Mark, \"The impact of the MIT-BIH arrhythmia database,\" IEEE Engineering in Medicine and Biology Magazine, vol. 20, no. 3, pp. 45–50, 2001.
[27] F. Pedregosa et al., \"Scikit-learn: Machine learning in Python,\" Journal of Machine Learning Research, vol. 12, pp. 2825–2830, 2011.
[28] World Health Organization, \"Cardiovascular diseases (CVDs): Key facts,\" 2021. [Online]. Available: https://www.who.int/news-room/fact-sheets/detail/cardiovascular-diseases-(cvds)
[29] A. Paszke et al., \"PyTorch: An imperative style, high-performance deep learning library,\" Advances in Neural Information Processing Systems (NeurIPS), vol. 32, 2019.
[30] T. Wolf et al., \"HuggingFace\'s Transformers: State-of-the-art natural language processing,\" arXiv:1910.03771, 2019.